;
(function() {
  // @mouseenter="addbgcolor($event, index0)"
  // @mouseleave="removebgcolor"
  Vue.component('treerbac', {
    template: `<div>
    <li v-for="(item0, index0) in model" class="framework-tree-list">
      <div
        :class="{ 'tree-padding-1': item0.level == 1 , 'tree-padding-2': item0.level == 2 , 'tree-padding-3': item0.level == 3 , 'tree-padding-4': item0.level == 4 , 'tree-padding-5': item0.level == 5 , 'tree-padding-6': item0.level == 6 , 'tree-padding-7': item0.level == 7 , 'tree-padding-8': item0.level == 8  }"
        class="userframework-title clearfix cursor ellipsis-1"
        @click.stop.prevent="toggle(index0, item0, $event)"
        :data-id="item0.id"
        :data-parentId="item0.parentId"
        :data-type="item0.type"
        :data-index="index0">
        <div class="pull-left z-50 relative">
          <span v-if="item0.orgType == 'DD'">
            <b class="inline text-center mr-5" v-if="item0.orgMemberType == 'CUSTOMER' && item0.level == '2' " style="width: 32px;height:22px;background:rgba(212,217,255,0.4);border-radius:2px;line-height:22px;font-size:12px;color:#766AD9;">客户</b>
            <b class="inline text-center mr-5" v-if="item0.orgMemberType == 'STAFF' && item0.level == '2'" style="width: 32px;height:22px;background:rgba(244,174,71,0.4);border-radius:2px;line-height:22px;font-size:12px;color:#F4AE47;">员工</b>
          </span>
          <span :class="{'icon-GMopen': osshow.indexOf(item0.id) > -1 , 'icon-Gm-prefix': osshow.indexOf(item0.id) == -1  }"></span>
          {{ item0.shortName }}
        </div>
        <div class="border-b tissue-border"></div>
      </div>
      <ul v-if="osshow.indexOf(item0.id) > -1">
        <treerbac
          class="item"
          :key="index0"
          @change="getPidData"
          :model="item0.children">
        </treerbac>
      </ul>
    </li>
    </div>`,
    props: {
      model: [Object, Array]
    },

    data: function() {
      return {
        open: false,
        index: 0,
        data: [],
        status: '',
        kid: null,
        osshow: []
      }
    },
    computed: {
      parentIdRabc() {
        return rbacVue.csid
      }
    },
    methods: {
      //点击展开并且调用下级菜单
      toggle: function(i, data, e) {

        this.index = i

        this.getPidData(data)

        if (this.osshow.indexOf(data.id) == -1) {
          this.osshow.push(data.id)
          return
        }
        if (this.osshow.indexOf(data.id) > -1) {
          this.osshow.map((item0, index0) => {
            if (item0 == data.id) {
              this.osshow.splice(index0, 1)
            }
          })
          return
        }

      },
      getPidData(id) {
        this.$emit('change', id)
      },

    },
    mounted() {

    }
  })
}())
